#!/usr/bin/env python
#coding:utf-8
import subprocess

def main():
    filename=r'c:/temp/log.log'
    logfile=open(filename,"a",0)
    popen = subprocess.Popen(r'ping 127.0.0.1 -n 10',stdout=subprocess.PIPE,stderr=subprocess.PIPE)
    for line in iter(popen.stdout.readline, ""):
        logfile.write(line)
        logfile.flush()
    logfile.close()

if __name__ == '__main__':
    main()
    print 'done'
